//
//  SMHHomeNavView.swift
//  SMHCommerce
//
//  Created by lvzhao on 2020/1/9.
//  Copyright © 2020 lvzhao. All rights reserved.
//

import UIKit
import SwiftyFitsize

class SMHHomeNavView: LZBaseView ,UITextFieldDelegate{

    
    
    override init(viewModel: LZBaseViewModel) {
        super.init(viewModel: viewModel)
        
        self.setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
 
    
    //MARK:textField
    func setupUI() {
        
        let textField = UITextField()
        textField.placeholder = "火热商品疯抢";
        textField.backgroundColor = UIColorFromHex(rgbValue: 0xF2F2F2)
        textField.delegate = self
        self.addSubview(textField)
        textField.layer.cornerRadius = 16~
        textField.clipsToBounds = true
        textField.snp.makeConstraints { (make) in
            make.left.equalTo(15~)
            make.bottom.equalTo(-10)
            make.height.equalTo(32)
            make.right.equalTo(-15~)
        }
        
        
        let searchImageView = UIImageView()
        searchImageView.image = UIImage.init(named: "icon_home_search")
        searchImageView.frame = CGRect(x: 15, y: 9, width: 14, height: 14)
        
        let leftView = UIView()
        leftView.frame = CGRect(x: 0, y: 0, width: 36, height: 32)
        textField.leftView = leftView
        textField.leftViewMode = .always
        
        textField.font = ktextFont(size: 14)
        textField.textColor = UIColor.black
        
        
        let attributedText = NSMutableAttributedString.init(string: textField.placeholder!, attributes: [.foregroundColor:UIColorFromHex(rgbValue: 0xA8A8A8)])
        textField.attributedPlaceholder = attributedText
        leftView.addSubview(searchImageView)
        
    }
}
